package byx.container.annotation.extension.impl;

import byx.container.annotation.annotation.Order;
import byx.container.annotation.extension.core.ParameterHandler;
import byx.container.annotation.extension.core.ParameterInfo;
import byx.container.core.Container;
import byx.container.core.ObjectFactory;

import static byx.container.core.ObjectFactories.fromContainer;

/**
 * 默认的参数处理器
 */
@Order(Integer.MAX_VALUE)
public class DefaultParameterHandler implements ParameterHandler {
    @Override
    public boolean support(ParameterInfo param) {
        return true;
    }

    @Override
    public ObjectFactory<?> handle(ParameterInfo param, Container container) {
        return fromContainer(container, param.getParameterType());
    }
}
